<?php

namespace App\Models;

use App\Wechat\Init;
use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class Qrcodeid extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'eb_qrcodeid';
    public $timestamps = false;
    public static function booted()
    {
        parent::booted();
        static::creating(function ($model){
            if(empty($model->qrcodeid)){
                $qrcodes=self::query()->pluck('qrcodeid')->toArray();
                $qrcodeid=1;
                while (in_array($qrcodeid,$qrcodes)){
                    $qrcodeid++;
                }
                $model->qrcodeid=$qrcodeid;
            }
        });
    }
}
